package vista;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JTextPane;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import modelo.Inspeccion;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VInspeccion extends javax.swing.JFrame {
	private JPanel panCliente;
	private JLabel lblTituloTaller;
	private JLabel lblPlacaAutoInspeccion;
	private JLabel lblDescripcionInspeccion;
	private JTextField txtDescripcionInspeccion;
	private JTextField txtPlacaAutoInspeccion;
	private JLabel lblCodInspeccion;
	private JTextField txtDCodPeritoInspeccion;
	private JLabel lblCodPeritoInspeccion;
	private JButton btnSalirInspeccion;
	private JButton btnCancelarInspeccion;
	private JButton btnModificar;
	private JButton btnBuscar;
	private JButton btnEliminarInspeccion;
	private JButton btnGuardarInspeccion;
	private JComboBox cmbAnno;
	private JComboBox cmbMes;
	private JComboBox cmbDia;
	private JLabel lblfechaInspeccion;
	private JTextField txtCodTaller;
	private JSeparator sptTituloCliente;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				VInspeccion inst = new VInspeccion();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public VInspeccion() {
		super("Cliente");
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Inspeccion");
			{
				panCliente = new JPanel();
				getContentPane().add(panCliente, BorderLayout.CENTER);
				panCliente.setLayout(null);
				panCliente.setBackground(new java.awt.Color(17,139,235));
				panCliente.setFont(new java.awt.Font("Bitstream Charter",0,14));
				panCliente.setPreferredSize(new java.awt.Dimension(711, 407));
				{
					lblTituloTaller = new JLabel();
					panCliente.add(lblTituloTaller);
					lblTituloTaller.setText("Informacion Inspeccion");
					lblTituloTaller.setBounds(160, 7, 284, 21);
					lblTituloTaller.setFont(new java.awt.Font("Andika Basic",1,18));
				}
				{
					sptTituloCliente = new JSeparator();
					panCliente.add(sptTituloCliente);
					sptTituloCliente.setBounds(65, 34, 502, 10);
				}
				{
					txtCodTaller = new JTextField();
					panCliente.add(txtCodTaller);
					txtCodTaller.setBounds(277, 92, 157, 22);
				}
				{
					lblDescripcionInspeccion = new JLabel();
					panCliente.add(lblDescripcionInspeccion);
					lblDescripcionInspeccion.setText("Descripcion:");
					lblDescripcionInspeccion.setBounds(88, 277, 106, 15);
				}
				{
					txtDescripcionInspeccion = new JTextField();
					panCliente.add(txtDescripcionInspeccion);
					txtDescripcionInspeccion.setBounds(273, 255, 308, 60);
				}
				{
					btnGuardarInspeccion = new JButton();
					panCliente.add(btnGuardarInspeccion);
					btnGuardarInspeccion.setText("Registrar Inspeccion");
					btnGuardarInspeccion.setBounds(34, 350, 150, 26);
					btnGuardarInspeccion.setBackground(new java.awt.Color(165,42,42));
				}
				{
					btnEliminarInspeccion = new JButton();
					panCliente.add(btnEliminarInspeccion);
					btnEliminarInspeccion.setText("Eliminar");
					btnEliminarInspeccion.setBounds(342, 350, 93, 26);
					btnEliminarInspeccion.setBackground(new java.awt.Color(173,216,230));
				}
				{
					btnCancelarInspeccion = new JButton();
					panCliente.add(btnCancelarInspeccion);
					btnCancelarInspeccion.setText("Cancelar");
					btnCancelarInspeccion.setBounds(445, 350, 93, 26);
					btnCancelarInspeccion.setBackground(new java.awt.Color(173,216,230));
				}
				{
					btnSalirInspeccion = new JButton();
					panCliente.add(btnSalirInspeccion);
					btnSalirInspeccion.setText("Salir");
					btnSalirInspeccion.setBounds(548, 350, 93, 26);
					btnSalirInspeccion.setBackground(new java.awt.Color(173,216,230));
				}
				{
					txtPlacaAutoInspeccion = new JTextField();
					panCliente.add(txtPlacaAutoInspeccion);
					txtPlacaAutoInspeccion.setBounds(276, 167, 155, 22);
				}
				{
					txtDCodPeritoInspeccion = new JTextField();
					panCliente.add(txtDCodPeritoInspeccion);
					txtDCodPeritoInspeccion.setBounds(273, 208, 184, 22);
				}
				{
					lblPlacaAutoInspeccion = new JLabel();
					panCliente.add(lblPlacaAutoInspeccion);
					lblPlacaAutoInspeccion.setBounds(88, 171, 200, 15);
					lblPlacaAutoInspeccion.setText("Placa del Auto");
					lblPlacaAutoInspeccion.setFont(new java.awt.Font("Bitstream Charter",0,14));
				}
				{
					lblCodPeritoInspeccion = new JLabel();
					panCliente.add(lblCodPeritoInspeccion);
					lblCodPeritoInspeccion.setText("Codigo Perito:");
					lblCodPeritoInspeccion.setBounds(88, 211, 134, 15);
					lblCodPeritoInspeccion.setFont(new java.awt.Font("Bitstream Charter",0,14));
				}
				{
					lblCodInspeccion = new JLabel();
					panCliente.add(lblCodInspeccion);
					lblCodInspeccion.setText("Codigo:");
					lblCodInspeccion.setFont(new java.awt.Font("Bitstream Charter",0,14));
					lblCodInspeccion.setBounds(88, 92, 200, 22);
				}
				{
					lblfechaInspeccion = new JLabel();
					panCliente.add(lblfechaInspeccion);
					lblfechaInspeccion.setText("Fecha:");
					lblfechaInspeccion.setBounds(88, 130, 60, 15);
				}
				{
					ComboBoxModel cmbDiaModel = 
							new DefaultComboBoxModel(
									new String[] { "01" , "02" , "03" , "04" , "05" , "06" , "07" , "08" , "09" ,"10" ,"11" ,"12" ,"13" ,"14" ,"15" ,"16" ,"17" ,"18" ,"19" ,"20" ,"21" ,"22" ,"23" ,"24" ,"25" ,"26" ,"27" ,"28" ,"29" ,"30" ,"31" });
					cmbDia = new JComboBox();
					panCliente.add(cmbDia);
					cmbDia.setModel(cmbDiaModel);
					cmbDia.setBounds(276, 127, 46, 22);
				}
				{
					ComboBoxModel cmbMesModel = 
							new DefaultComboBoxModel(
									new String[] { "01" , "02" , "03" , "04" , "05" , "06" , "07" , "08" , "09" , "10" , "11" , "12" });
					cmbMes = new JComboBox();
					panCliente.add(cmbMes);
					cmbMes.setModel(cmbMesModel);
					cmbMes.setBounds(331, 127, 46, 22);
				}
				{
					ComboBoxModel cmbAnnoModel = 
							new DefaultComboBoxModel(
									new String[] { "2012" , "2013" , "2014" , "2015" , "2016" , "2017" , "2018" , "2019" , "2020" , "2021" , "2022" , "2023" , "2024" , "2025" });
					cmbAnno = new JComboBox();
					panCliente.add(cmbAnno);
					cmbAnno.setModel(cmbAnnoModel);
					cmbAnno.setBounds(386, 127, 64, 22);
				}
				{
					btnBuscar = new JButton();
					panCliente.add(btnBuscar);
					btnBuscar.setText("Buscar");
					btnBuscar.setBackground(new java.awt.Color(165,42,42));
					btnBuscar.setBounds(464, 90, 88, 26);
				}
				{
					btnModificar = new JButton();
					panCliente.add(btnModificar);
					btnModificar.setText("Modificar");
					btnModificar.setBounds(222, 350, 93, 26);
					btnModificar.setBackground(new java.awt.Color(173,216,230));
				}
			}
			pack();
			this.setSize(662, 425);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	public void agregarListener(ActionListener accion)  {
		this.btnCancelarInspeccion.addActionListener(accion);
		this.btnGuardarInspeccion.addActionListener(accion);
		this.btnSalirInspeccion.addActionListener(accion);
		this.btnEliminarInspeccion.addActionListener(accion);
		this.btnBuscar.addActionListener(accion);
		this.btnModificar.addActionListener(accion);
}
	
	

	public void limpiarDatos(){
		
		this.cmbAnno.setSelectedIndex(0);
		this.cmbDia.setSelectedIndex(0);
		this.cmbMes.setSelectedIndex(0);
		this.txtCodTaller.setText("");
		this.txtDCodPeritoInspeccion.setText("");
		this.txtDescripcionInspeccion.setText("");
		this.txtPlacaAutoInspeccion.setText("");
	}
	
	
	
	
	public void bloquearDatos(boolean valor){
		this.txtCodTaller.setEnabled(valor);
		this.txtDCodPeritoInspeccion.setEnabled(valor);
		this.txtDescripcionInspeccion.setEnabled(valor);
		this.txtPlacaAutoInspeccion.setEnabled(valor);
		
	}
	
	public void setDatos(String codtaller, String codperito, String desinspeccion){
		
		this.txtCodTaller.setText(codtaller);
		this.txtDCodPeritoInspeccion.setText(codperito);
		this.txtDescripcionInspeccion.setText(desinspeccion);
		
		
	}
	
	
	
	public void habilitarModificacion(boolean valor){
		this.btnModificar.setVisible(valor);
		//this.btnGenerarEstadistica.setEnabled(valor);
	}

	
	
	
	
	public void mostrarMensaje(String mensaje){
		JOptionPane.showMessageDialog(this, mensaje);
	}
	
	public String getCodigo(){
    	return txtCodTaller.getText().trim();
    }
	
	public String getPlaca(){
    	return txtPlacaAutoInspeccion.getText();
    }
	public String getCodPerito(){
    	return txtDCodPeritoInspeccion.getText();
    }
	public String getDescripcion(){
    	return txtDescripcionInspeccion.getText();
    }
	
	public String getFecha(){
		return this.cmbDia.getSelectedItem().toString()+"/"+this.cmbMes.getSelectedItem().toString()+"/"+this.cmbAnno.getSelectedItem().toString();
	}
	
	   public boolean Chequear(){
       	
       	if (txtCodTaller.getText().equals("") || txtDCodPeritoInspeccion.getText().equals("") || txtDescripcionInspeccion.getText().equals("")
       			|| txtPlacaAutoInspeccion.getText().equals(""))
       		return true;
       	return false;
       }

	public void mostrarInspeccion(Inspeccion inspec) {
		this.txtCodTaller.setText(inspec.getIns_cod());
		this.txtDCodPeritoInspeccion.setText(inspec.getIns_codperito());
		this.txtDescripcionInspeccion.setText(inspec.getIns_descrp());
		this.txtPlacaAutoInspeccion.setText(inspec.getIns_aut());
		int aux1;
		
		aux1 = Integer.parseInt(inspec.getIns_fec().substring(0, 2));
		cmbDia.removeAll();
		aux1--;
		cmbDia.setSelectedIndex(aux1);
			
		aux1 = Integer.parseInt(inspec.getIns_fec().substring(3, 5));
		aux1--;
		cmbMes.removeAll();
		cmbMes.setSelectedIndex(aux1);
		
		aux1 = Integer.parseInt(inspec.getIns_fec().substring(6, 10));
		aux1 -= 2012;
		cmbAnno.removeAll();
		cmbAnno.setSelectedIndex(aux1);
	}
       
	

}


